<?php

	$TEMP->set_file(array('handle' => DIR_IFRAME_VIEW . 'printStudentGradesSearch.html'));
	
	$getSubject = $DSC->getSubject($_GET['txtsubject']);
	
	$studList = $STUD->arraySearchStudentInformation($activeYear, $_GET);
	
	$strGrades = $DSC->gradeConvertion();
	//r_print($studList);
	if ( !empty($studList) ) {
		$TEMP->set_block('handle',  'students', 'studentsRow');
		$numCount 	= 1;
		foreach($studList as $studListField => $studListValue) {
			
			$studID 		= $studListValue['stud_idPK'];
			$courseID 		= $studListValue['course_idFK'];
			
			$semActiveFreshmen	= $STUD->getSemesterEnrollmentActive($studID);
			$currentSemester	= $DSC->getSemesterLabel($semActiveFreshmen['sem_linker_idFK']);
			$takeSectionDesc	= $STUD->getStudSectionDesc($studID, $courseID, $semActiveFreshmen['sem_linker_idFK']);
			
			$initSemActive			= $STUD->getSemesterEnrollmentActive($studID);
			$studentSubjectListVal 	= $STUD->getStudentSubjectGrades($studID, $_GET['txtsubject'], $studListValue['course_idFK'], $initSemActive['sem_linker_idFK']);
			
			if (!empty($studentSubjectListVal['grade'])) {
				/*if ($studentSubjectListVal['grade'] == 'INC' || $studentSubjectListVal['grade'] == 'DRP') {
					$percentSymbol = '';
					$gradeConvert = ($studentSubjectListVal['grade'] == 'INC') ? '<span class="font-red">INC</span>' : '<span class="font-red">DROP</span>';
				}
				else {
					if ( !in_array($studentSubjectListVal['grade'], $strGrades) ) {
						$gradeIfPercent = $globalCon->getGradeIfPercent($studentSubjectListVal['grade']);
						$percentSymbol 	= ( $gradeIfPercent === true ) ? '' : '%';
						$gradeConvert 	= $studentSubjectListVal['equivalence'];
					}
					else {
						$percentSymbol 	= '';
						$gradeConvert 	= '--';
					}
				}*/
				
				$gradeConvertion 	 = $STUD->gradeConvertion($studentSubjectListVal['grade']);
				$studSubjGradeValue  = $studentSubjectListVal['grade'];
				$gradeConvertRemarks = $gradeConvertion['description'];
						
			}
			else {
				$studSubjGradeValue  = '&nbsp;';
				$gradeConvertRemarks = '&nbsp;';
			}
			
			$grades				= '<div class="subject-grades">
										<div class="subject-grades-value">
											&nbsp;' . $studentSubjectListVal['grade'] . $percentSymbol . '
										</div>
										<div class="subject-grades-convert">
											&nbsp;&nbsp;' . $gradeConvert . '
										</div>
									</div>';
			
			$TEMP->set_var(array('stud_id' 		=> $studListValue['stud_idPK'],
								 'stud_no' 		=> $studListValue['stud_no'],
								 'name' 		=> $studListValue['last_name'] . ', ' . $studListValue['first_name'] . ' ' . $studListValue['middle_name'],
								 'course_code'	=> $studListValue['course_code'],
								 'if_enroll'	=> $ifPaymentFull,
								 'section' 		=> ($takeSectionDesc['section_desc'] == '') ? '------------' : $takeSectionDesc['section_desc'],
								 'numbering'	=> $numCount.'.',
								 'grades'		=> $studSubjGradeValue,
								 'remarks'		=> $gradeConvertRemarks
								));
								
			$TEMP->parse('studentsRow', 'students', true);
			$bgcolor = ($bgcolor == LOOPING_F0F) ? LOOPING_FFF : LOOPING_F0F;
			$numCount++;
		}
	}
	else {
		$TEMP->set_var(array('stud_id' 		=> '',
							 'stud_no' 		=> '',
							 'name' 		=> '',
							 'course_code'	=> '',
							 'if_enroll'	=> '',
							 'section' 		=> '',
							 'numbering'	=> '',
							 'sy_label'		=> '',
							));
	}
	$TEMP->set_var(array('sy_label'	=> $__SYR__, 'subject' => $getSubject['subj_desc']));
	
?>